package com.hyq.learn.api.validator;

import jakarta.validation.Constraint;
import jakarta.validation.Payload;

import java.lang.annotation.Documented;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * 使用注解进行属性的校验。
 *
 * @author : heyuqin
 * @since : 2024/04/10 11:46
 */
@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER})
@Retention(RUNTIME)
@Documented
@Repeatable(EnumValid.List.class)
@Constraint(validatedBy = {EnumValidator.class})
public @interface EnumValid {
    String message() default "无当前枚举类型";
    // 分组
    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

//    ResultGetType[] value();


    @Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER})
    @Retention(RUNTIME)
    @Documented
    public @interface List {
        EnumValid[] value();
    }
}
